package demoMod.invincibleOne.cards.invincible;

import com.megacrit.cardcrawl.actions.animations.VFXAction;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.GainBlockAction;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.ThornsPower;
import demoMod.invincibleOne.InvincibleOneMod;
import demoMod.invincibleOne.enums.AbstractCardEnum;
import demoMod.invincibleOne.enums.CardTagsEnum;
import demoMod.invincibleOne.powers.OiledThornsPower;

import java.util.stream.Collectors;

public class FlameBarrier extends AbstractInvincibleCard {
    public static final String ID = InvincibleOneMod.makeID("FlameBarrier");

    private static final CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;
    public static final String IMG_PATH = "cards/FlameBarrier.png";

    private static final CardType TYPE = CardType.SKILL;
    private static final CardRarity RARITY = AbstractCardEnum.LEGENDARY;
    private static final CardTarget TARGET = CardTarget.NONE;

    private static final int COST = -2;

    public FlameBarrier() {
        super(ID, NAME, InvincibleOneMod.getResourcePath(IMG_PATH), COST, DESCRIPTION, TYPE, RARITY, TARGET);
        this.baseMagicNumber = this.magicNumber = 4;
        this.baseBlock = this.block = 12;
        this.tags.add(CardTagsEnum.VIRUS);
    }

    @Override
    public Runnable getUpgradeAction() {
        return () -> {
            upgradeMagicNumber(2);
            upgradeBlock(4);
        };
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        for (AbstractMonster mo : AbstractDungeon.getMonsters().monsters.stream().filter(mo -> !mo.isDeadOrEscaped()).collect(Collectors.toList())) {
            addToBot(new ApplyPowerAction(mo, mo, new OiledThornsPower(mo, this.magicNumber)));
            addToBot(new GainBlockAction(mo, this.baseBlock));
        }
    }
}
